// components/index-home/user-info/index.js
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
const storageManager = require('../../../manager/storageManager')

Component({
  properties: {},
  data: {
    userInfo: { avatarUrl: defaultAvatarUrl, nickName: '' },
    userLevel: 1
  },
  lifetimes: {
    attached() {
      const userInfo = storageManager.getStorage(storageManager.STORAGE_KEYS.USER_INFO) || { avatarUrl: defaultAvatarUrl, nickName: '' }
      const learningData = storageManager.getStorage(storageManager.STORAGE_KEYS.LEARNING_DATA) || { level: 1 }
      this.setData({
        userInfo,
        userLevel: learningData.level || 1
      })
    }
  },
  methods: {}
})
